<template>
	<view class='content'>
		<view v-for="(item,index) in bookRecordList" class="bookBox" :key="index">
			<view class="bookMessage">
				<span style="font-weight: 400;font-size: 16px;">书籍名称:{{ item.bookName }}</span>
				<span>作者名称:{{ item.bookAuthor }}</span>
				<span>借书期限:{{ item.leaseTime }}(天)</span>
				<span>借书时间:{{ item.beginTime }}</span>
				<span v-if="item.isReturn == 1">还书时间:{{ item.returnTime }}</span>
			</view>
			<view style="text-align: center;flex-direction: column;">
				<view v-if="item.isReturn == 1" style="display: flex;flex-direction: column;">
					<u-icon name="checkbox-mark" color="#2979ff" size="60"></u-icon>
					<span>已归还</span>
				</view>
				<view v-if="item.isReturn == 0" style="display: flex;flex-direction: column;">
					<u-icon name="error-circle" color="#2979ff" size="45"></u-icon>
					<span>未归还</span>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
import { getBookRecord } from '@/utils/book.js';
export default {
	data() {
		return {
			//用户id
			leaseUserId:'',
			//借书记录
			bookRecordList:[],
		};
	},
	methods: {
		getList(){
			let params = {
				leaseId:this.leaseUserId
			}
			getBookRecord(params).then((res)=>{
				if(res.code == 200){
					this.bookRecordList = res.data
					console.log(this.bookRecordList)
					this.bookRecordList.forEach((item,index) =>{
						item.beginTime = item.beginTime.split('T')[0]
						if(item.returnTime){
							item.returnTime = item.returnTime.split('T')[0]
						}
					})
				}
			})
		}
	},
	created() {

	},
	onLoad(e) {
		this.leaseUserId = JSON.parse(decodeURIComponent(e.key))
		this.getList()
	}
};
</script>

<style>
page {
	background-color: #f2f2f2;
}
.content {
	width: 750rpx;
	height: 100vh;
	padding: 20px;
}
.bookBox{
	width:85%;
	display: flex;
	justify-content: space-around;
	margin:10px;
	background-color: white;
	align-items: center;
	border-radius: 10px;
	padding:20px;
}
.bookMessage{
	display: flex;
	flex-direction: column;
	font-family: fangsong;
}
</style>
